using System;
using System.Drawing;
using System.Windows.Forms;

namespace Linquid
{
	internal class GroupBox: Control
	{
		private const int Shift = 5;		
		public GroupBox(): base(){}

		public readonly int LeftMargin = 5;
		public readonly int RightMargin = 5;
		public readonly int BottomMargin = 5;
		public int TopMargin
		{
			get {return (int) Font.GetHeight() + BottomMargin;}
		}
		
		protected override void OnPaint(PaintEventArgs args)
		{
			var graphics = args.Graphics;
			var size = graphics.MeasureString(Text, Font);
			var width = (int) size.Width;
			var halfHeight = (int) size.Height / 2;
			
			using (var brush = new SolidBrush(Color.Black))
			{				
				graphics.DrawString(Text, Font, brush, Shift + 1, 0);				
			}
						
			using (var pen = new Pen(Color.Black, 2.0f))
			{
				graphics.DrawLine(pen, 1, halfHeight, 1, Height - 2);
				graphics.DrawLine(pen, 1, halfHeight + 1, Shift, halfHeight + 1);
				graphics.DrawLine(pen, 1, Height - 2, Width - 2, Height - 2);
				graphics.DrawLine(pen, Width - 2, halfHeight, Width - 2, Height - 2);
				graphics.DrawLine(pen, width + Shift, halfHeight + 1, Width - 2, halfHeight + 1);
			}			
		}
		
	}
}
